<template>
  <div>
    <div>
      <input ref="updateToken"/>
      <button @click="update">设置token</button>
      <button @click="del">删除token</button>
    </div>
    <div>
      当前token：<label>{{ token }}</label>
    </div>
  </div>
</template>

<script>
import Cookies from 'js-cookie';

export default {
  name: 'Cookie',
  data(){
    return {
      token: null
    }
  },
  created :function(){
    this.token = Cookies.get('token');
  },
  methods:{
    update(){
      let updateToken = this.$refs.updateToken.value;
      console.log("updateToken = ", updateToken);
      Cookies.set('token', updateToken);
      this.token = updateToken;
    },
    del(){
      Cookies.remove("token");
      this.token = Cookies.get("token");
    }
  }
}
</script>
